#课本案例
# .join 方法  list 转换 str
# list的方法能够打乱和改变list的内容
# phrase = "Don't panic!"
# plist = list(phrase)
# print(phrase)
# # print(plist)
#
# new_phrase = ''.join(plist[1:3])
# new_phrase = new_phrase + ''.join([plist[5],plist[4],plist[7],plist[6]])
#
# print(plist)
# print(new_phrase)
# import random
#
# #p48
# wait_time = random.randint(1,60)
# print(wait_time)
#
# word = "bottles"
# print(word)
#
# # p56
# vowels = ['a','e','i','o','u']
# print(vowels)
#
# word2 = "Milliways"
# print(word2)
# for letter in word2:
#     if letter in vowels:
#         print(letter)

#
# #p58
# found = []
# print(len(found))
#
# found.append('a')
# print(len(found))
# print(found)
#
# found.append('e')
# found.append('i')
# found.append('o')
# print(len(found))
# print(found)
#
# #p59
#
# if 'u' not in found:
#     found.append('u')
# print(found)
# if 'u' not in found:
#     found.append('u')

#60、61

# vowels = ['a','e','i','o','u']
# word = input("请输入查询的单词：")
# found = []
# for letter in word:
#     if letter in vowels:
#         if letter not in found:
#             found.append(letter)
# for vowel in found:
#     print(vowel)

# #p62
# nums = [1,2,3,4]
# print(nums)
#
# nums.remove(3)
# print(nums)
# #p63
# nums.pop()
# print(nums)
#
# nums.pop(0)
# print(nums)
#
# #p64
# nums.extend([3,4])
# print(nums)
#
# nums.extend([])
# print(nums)
#
# #p65
# nums.insert(0,1)
# print(nums)
# nums.insert(2,"two-and-a-half")
# print(nums)

#p68
# phrase = "Don’t panic!"
# plist = list(phrase)
# print(phrase)
# print(plist)
# plist.pop(0)
# plist.remove("’")
# plist.pop()
# plist.pop()
# plist.pop()
# plist.pop()
# plist[2],plist[3],plist[4],plist[5] = plist[3],plist[2],plist[5],plist[4]
# new_phrase = ''.join(plist)
# print(plist)
# print(new_phrase)

# #p72
# first = [1,2,3,4,5]
# print(first)
#
# second = first
# print(second)
#
# second.append(6)
# print(second)
# print(first)
#
# #p73
#
# third = second.copy()
# print(third)
#
# third.append(7)
# print(third)
# print(second)
# print(first)

#p75
# saying = "Don't panic!"
# letters = list(saying)
# print(letters)
#
# print(letters[0])
# print(letters[3])
# print(letters[6])
# print(letters[-1])
# print(letters[-3])
# print(letters[-6])
#
# #p77
# print(letters)
# print(letters[0:10:3])
# print(letters[3:])
# print(letters[:10])
# print(letters[::2])

#p78
# book = "The Hitchhiker's Guide to the Galaxy"
# booklist = list(book)
# print(booklist)
# print(booklist[0:3])
# print(''.join(booklist[0:3]))
# print(''.join(booklist[-6:]))
#
# #p79
# backwards = booklist[::-1]
# print(backwards)
# print(''.join(backwards))
# every_other = booklist[::2]
# print(''.join(every_other))
# print(''.join(booklist[4:14]))
# print(''.join(booklist[13:3:-1]))

#p88
paranoid_android = "Marvin, the Paranoid Android"
letters = list(paranoid_android)

for char in letters[:6]:
    print('\t',char)
for char in letters[-7:]:
    print('\t'*2,char)
for char in letters[12:20]:
    print('\t'*3,char)

